package service

import (
	"context"
	com_model "elflog/common/com-model"
	"elflog/common/utils/id_util"
	"elflog/module/module-log/model"
	"time"
)

func (a *ModuleLogService) CreateLog(ctx context.Context, log *model.CreateLogModel) error {
	err := a.dao.Dao.GetDb(ctx).Create(&model.Log{
		Model: com_model.Model{
			Id:        id_util.GetUuid(),
			CreatedAt: time.Now(), UpdatedAt: time.Now(), DeletedAt: nil,
		},
		AccountId:  log.AccountId,
		LoggerId:   log.LoggerId,
		LoggerName: log.LoggerName,
		AppName:    log.AppName,
		AppVersion: log.AppVersion,
		AppHost:    log.AppHost,
		RemoteIp:   log.RemoteIp,
		ModuleName: log.ModuleName,
		FuncName:   log.FuncName,
		ClientId:   log.ClientId,
		Time:       log.Time,
		TraceId:    log.TraceId,
		UserId:     log.UserId,
		Message:    log.Message,
		Content:    log.Content,
		Level:      log.Level,
	}).Error
	return err
}
